﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace FlexySys.Common.Encription
{

    public static class Hashing
    {
        public static string ComputeSHA1(string text)
        {
            using (SHA1 sha1 = new SHA1CryptoServiceProvider())
            {
                byte[] textByte = Encoding.Default.GetBytes(text);
                byte[] retVal = sha1.ComputeHash(textByte);
                return BitConverter.ToString(retVal); // hex string
            }
        }

        public static string ComputeSHA512(string text)
        {
            using (SHA512 sha512 = new SHA512Managed())
            {
                byte[] textByte = Encoding.Default.GetBytes(text);
                byte[] retVal = sha512.ComputeHash(textByte);
                return BitConverter.ToString(retVal);
            }
        }

        public static string ComputeMD5(string text)
        {
            using (MD5 md5 = new MD5CryptoServiceProvider())
            {
                byte[] textByte = Encoding.Default.GetBytes(text);
                byte[] retVal = md5.ComputeHash(textByte);
                return BitConverter.ToString(retVal); // hex string
            }
        }
    }

}
